<?php

require_once dirname(__FILE__).'/../lib/participation_detailGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/participation_detailGeneratorHelper.class.php';

/**
 * participation_detail actions.
 *
 * @package    sf_sandbox
 * @subpackage participation_detail
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12474 2008-10-31 10:41:27Z fabien $
 */
class participation_detailActions extends autoParticipation_detailActions
{
  protected function processForm(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $this->getUser()->setFlash('notice', $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.');

      $participation_detail = $form->save();

      $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $participation_detail)));

      if ($request->hasParameter('_save_and_add'))
      {
        $this->getUser()->setFlash('notice', $this->getUser()->getFlash('notice').' You can add another one below.');

        $this->redirect('@participation_detail_new');
      }
      else
      {
        $this->redirect('@participation_show?id='.$participation_detail['participation_id']);
      }
    }
    else
    {
      $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.');
    }
  }
  public function executeDelete(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $this->dispatcher->notify(new sfEvent($this, 'admin.delete_object', array('object' => $this->getRoute()->getObject())));

    $this->participation_detail=$this->getRoute()->getObject();
    $participation_id=$this->participation_detail["participation_id"];
    $this->participation_detail->delete();

    $this->getUser()->setFlash('notice', 'The item was deleted successfully.');

    $this->redirect('@participation_show?id='.$participation_id);
  }
}
